<?php
$smarty->configLoad($lang . '/myprofile.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['profile'];
if(empty($_GET['userID'])) {
	$_GET['userID'] = $_SESSION['id'];
} 
$sql = 'SELECT * FROM ' . DB_LOGIN . '.account_data WHERE id = :id';
$dbh = $connection->prepare($sql);
if (isset($_GET['userID'])) {
    $dbh->bindValue(':id', $_GET['userID']);
} else {
    $dbh->bindValue(':id', $_SESSION['id']);
}
$dbh->execute();
foreach ($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
	$row['access'] = $main->getRights($row['access_level']);
    $value[] = $row;
}
$smarty->assign('value', $value);

$sql = 'SELECT * FROM '.DB_GAME.'.players WHERE account_id = :id';
$dbh = $connection->prepare($sql);
if (isset($_GET['userID'])) {
    $dbh->bindValue(':id', $_GET['userID']);
} else {
    $dbh->bindValue(':id', $_SESSION['id']);
}
$dbh->execute();
$ch = new character;
$character = '';
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $char) {
	$char['level'] = $ch->getLevel($char['exp']);
	$char['class'] = $ch->getClass($char['player_class'], 1);
	$char['race'] = $ch->getRace($char['race'], 3, 1);
	$character[] = $char;
}
$smarty->assign('character', $character);
$smarty->assign('userID', $_GET['userID']);
$template = 'profile/index.tpl';
?>
